﻿package mortal.game.view.mainUI.zazen
{
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.cd.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guide.*;

    public class ZazenIncomeView extends RightDownShrinkView
    {
        protected var _totalTime:GTextFiled;
        protected var _exp:GTextFiled;
        protected var _life:GTextFiled;
        protected var _mana:GTextFiled;
        protected var _secTimeViewData:SecTimerViewData;
        private var totalNumbus:int;
        private var totalExp:int;
        private var totalLife:int;
        private var totalMana:int;
        private static var _instance:ZazenIncomeView;

        public function ZazenIncomeView()
        {
            super(ImagesConst.ZazenGetDetail, ImagesConst.ZazenGet);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.ZazenDes, 15, 50, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.GuajiTongjiLine, 0, 85, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.ZazenTime, 17, 110, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.ZazenExp, 148, 110, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.LifeGet, 14, 136, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.ManaGet, 145, 136, _bodySprite));
            this._totalTime = UIFactory.gTextField(Language.getString(35389), 79, 109, 160, 20, _bodySprite);
            this._exp = UIFactory.gTextField("0", 212, 109, 160, 20, _bodySprite);
            this._life = UIFactory.gTextField("0", 79, 135, 160, 20, _bodySprite);
            this._mana = UIFactory.gTextField("0", 212, 135, 160, 20, _bodySprite);
            if (!this._secTimeViewData)
            {
                this._secTimeViewData = new SecTimerViewData();
                this._secTimeViewData.setLeftTime(int.MAX_VALUE);
            }
            this._secTimeViewData.reset();
            this._secTimeViewData.start();
            this._secTimeViewData.caller = this.updateTime;
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show(param1, param2);
            if (GuideAutoFightWin.hasInstance && !GuideAutoFightWin.instance.isHide)
            {
                GuideAutoFightWin.instance.hide();
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._totalTime.dispose(param1);
            this._totalTime = null;
            this._exp.dispose(param1);
            this._exp = null;
            this._life.dispose(param1);
            this._life = null;
            this._mana.dispose(param1);
            this._mana = null;
            this.totalNumbus = 0;
            this.totalExp = 0;
            this.totalLife = 0;
            this.totalMana = 0;
            this._secTimeViewData.stop();
            super.disposeImpl(param1);
            return;
        }// end function

        public function addNimbus(param1:int) : void
        {
            this.totalNumbus = this.totalNumbus + param1;
            return;
        }// end function

        public function addExp(param1:int) : void
        {
            this.totalExp = this.totalExp + param1;
            if (this._exp)
            {
                this._exp.text = this.totalExp.toString();
            }
            return;
        }// end function

        public function addLife(param1:int) : void
        {
            this.totalLife = this.totalLife + param1;
            if (this._life)
            {
                this._life.text = this.totalLife.toString();
            }
            return;
        }// end function

        public function addMana(param1:int) : void
        {
            this.totalMana = this.totalMana + param1;
            if (this._mana)
            {
                this._mana.text = this.totalMana.toString();
            }
            return;
        }// end function

        public function updateTime() : void
        {
            var _loc_1:* = this._secTimeViewData.leftTime;
            var _loc_2:* = Language.getString(35390);
            if (_loc_1 > 3600)
            {
                _loc_2 = Language.getString(35391);
            }
            this._totalTime.text = this._secTimeViewData.parse(_loc_2);
            return;
        }// end function

        public static function get instace() : ZazenIncomeView
        {
            if (!_instance)
            {
                _instance = new ZazenIncomeView;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
